#include "ZUIUtils.h"
#include <QFile>
#include <QDebug>

ZUIUtils::ZUIUtils()
{

}

QString ZUIUtils::loadStyleSheet(const QString &path)
{
    QString qss;

    QFile file(path);
    bool ok = file.open(QFile::ReadOnly);
    if (ok)
    {
        qss = file.readAll();
        file.close();
    }
    else
    {
        qCritical() << Q_FUNC_INFO << file.errorString();
    }

    return qss;
}

QTableWidgetItem *ZUIUtils::getItem(QTableWidget *table, int row, int col)
{
    Q_ASSERT(table);
    Q_ASSERT(row < table->rowCount());
    Q_ASSERT(col < table->columnCount());

    QTableWidgetItem *item = table->item(row, col);
    if (!item)
    {
        item = new QTableWidgetItem;
        table->setItem(row, col, item);
    }

    return item;
}
